package com.by.api.feign;

import org.springframework.core.io.InputStreamResource;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 江俊俊
 * @version 1.0
 * @description
 * @date 2025/4/16 20:36
 * @since JDK1.8
 */
@FeignClient("sc-minio")
public interface MinioFeignClient {

    /**
     * 上传文件
     * @param file
     * @return
     */
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    String uploadFile(@RequestPart("file") MultipartFile file);

    /**
     * 下载文件
     * @param filePath
     * @return
     */
    @GetMapping("/download")
    ResponseEntity<InputStreamResource> downloadFile(String filePath);

    /**
     * 删除文件
     * @param filePath
     * @return
     */
    @DeleteMapping("/delete")
    int deleteFile(String filePath);
}
